package mortal.game.control
{
    import Message.Public.*;
    import flash.utils.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.view.friendsBless.*;
    import mortal.game.view.uiIconBtn.*;
    import mortal.mvc.core.*;

    public class FriendsBlessController extends Controller
    {
        private var _blessHintIcon:BlessHintIcon;
        private var _blessHintIconFu:BlessHintIconFu;
        private var _blessHintIconFuDic:Dictionary;
        private var _blessReceivePanel:FriendBlessReceivePanel;
        public var sendBlessCount:int = 0;

        public function FriendsBlessController()
        {
            this._blessHintIconFuDic = new Dictionary();
            
        }

        override protected function initServer() : void
        {
            Dispatcher.addEventListener(EventName.FriendBless_ShowBlessesList, this.onShowBlessesList);
            NetDispatcher.addCmdListener(ServerCommand.FriendBlessSuccess, this.onFriendBlessSuccess);
            NetDispatcher.addCmdListener(ServerCommand.FriendBlessTips, this.onFriendBlessTipsCommand);
            NetDispatcher.addCmdListener(ServerCommand.FriendBlessList, this.onFriendBlessTipsCommand);
            
        }

        private function onShowBlessesList(event:DataEvent) : void
        {
            if (!this._blessReceivePanel)
            {
                this._blessReceivePanel = new FriendBlessReceivePanel();
            }
            this._blessReceivePanel.showBlessReceive(event.data as Array);
            
        }

        private function onFriendBlessSuccess(param1:SFriendBlessSucess) : void
        {
            if (!this._blessReceivePanel || this._blessReceivePanel && this._blessReceivePanel.isHide)
            {
                if (!this._blessHintIconFu)
                {
                    this._blessHintIconFu = new BlessHintIconFu();
                }
                this._blessHintIconFu.showIcon([param1]);
                UiHintIconView.instance.addHintIcon(this._blessHintIconFu);
            }
            else
            {
                this._blessReceivePanel.showBlessReceive([param1]);
            }
            
        }

        private function onFriendBlessTipsCommand(param1:Array) : void
        {
            if (!this._blessHintIcon)
            {
                this._blessHintIcon = new BlessHintIcon();
            }
            this._blessHintIcon.showIcon(param1);
            UiHintIconView.instance.addHintIcon(this._blessHintIcon);
            
        }

    }
}
